<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <router-link to="/user">用户功能</router-link>
    <router-view></router-view>
  </div>  
</body>
<script src="../lib/vue.js"></script>
<script src="./lib/vue-router.js"></script>
<script>
  // 定义组件
  var User = {
    template: `
      <div>
        <router-link to="/user/hobby">爱好</router-link>  
        <router-view></router-view>  
      </div>
    `
  }
  var Info = {
    template: `<div>info</div>`
  }

  var routes = [
    {
      path: '/user',
      component: User,
      children: [
        {
          path: 'hobby',
          component: Info
        }
      ]
    }
  ]

  var router = new VueRouter({
    routes
  })

  // 创建vue实例
  new Vue({
    el: "#app",
    router
  })
</script>
</html>